pygame how to change a pictures hue

83

pygame how to change a pictures hue -

blue_rgb = (0,0,255)
red_rgb = (255,0,0)
img = pygame.image.load("sky_picture.png") # loads the picture from the path given
var = pygame.PixelArray(img)
# var.replace(([Colour you want to replace]), [Colour you want])
var.replace((blue_rgb), (red_rgb)) # replaces all blue in the picture to red
del var 
# if the picture has some unchanged pixels left it's probably because they are not EXACTLY the rgb given for example (254,0,0) is not (255,0,0) and won't be changed (to fix this you will have to calculate the approx number ot just change the main picture)

Comments

Submit
0 Comments